//
//  BbarcodeLoginViewController.m
//  HCNewGoldFinger
//
//  Created by zjhcsoft on 16/7/12.
//  Copyright © 2016年 zjhcsoftios. All rights reserved.
//

#import "BbarcodeLoginViewController.h"
#import "iSeeNetworkRequest.h"

#define iSEESCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)

@interface BbarcodeLoginViewController ()

@end

@implementation BbarcodeLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle bundleForClass:[self class]] URLForResource:@"NewMarketLib" withExtension:@"bundle"]];

    UIImageView *imageview =[[UIImageView alloc] initWithFrame:CGRectMake(65, 80, iSEESCREEN_WIDTH -130, 160)];
    imageview.image = [UIImage imageNamed:@"pc" inBundle:bundle compatibleWithTraitCollection:nil];
    
 
    [self.view addSubview:imageview];
    
    UIButton *truebutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [truebutton setFrame:CGRectMake(50, 300, iSEESCREEN_WIDTH - 100, 40)];
    [truebutton setTitle:@"确定" forState:UIControlStateNormal];
    [truebutton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [truebutton addTarget:self action:@selector(trueAction:) forControlEvents:UIControlEventTouchUpInside];
    truebutton.layer.cornerRadius = 8;
    [truebutton.layer setBorderWidth:1];
    [truebutton setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];

    CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
    
    CGColorRef color = CGColorCreate(colorSpaceRef, (CGFloat[]){0,255,0,1});
    [truebutton.layer setBorderColor:color];
    [self.view addSubview:truebutton];
    
    
    UIButton *cancelbutton = [UIButton buttonWithType:UIButtonTypeCustom];
    [cancelbutton setFrame:CGRectMake(50, 360, iSEESCREEN_WIDTH - 100, 30)];
    [cancelbutton addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
    [cancelbutton setTitle:@"取消登陆" forState:UIControlStateNormal];
    [cancelbutton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.view addSubview:cancelbutton];
    self.view.backgroundColor =[UIColor whiteColor];

}

-(void)trueAction:(UIButton *)btn{
    
    NSMutableDictionary *prame =[[NSMutableDictionary alloc] init];
    
    [prame setObject:_code forKey:@"code"];
    
    [iSeeNetworkRequest getWithHeaderUrl:[NSString stringWithFormat:@"%@%@", NMarketMainUrl,QrCodeLogin] params:prame success:^(id object) {
        [self.delegate popview];
        [self dismissViewControllerAnimated:YES completion:nil];
    } failure:^(NSError *error) {
        
    }];
    
//    [FZNetworking erweimadengluurl:prame success:^(id object) {
//        if ([object[@"code"] integerValue] == 200) {
//            [_delegate popview];
//            [self dismissModalViewControllerAnimated:YES];
//        }
//
//    } fail:^(id object) {
//        [SVProgressHUD showErrorWithStatus:@"登陆失败"];
//    }];

   
}

-(void)cancelAction:(UIButton *)btn{
    [_delegate popview];

    [self dismissViewControllerAnimated:YES completion:nil];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
